package com.vca.common.utils;

import com.github.binarywang.java.emoji.EmojiConverter;

/**
 * @author chenbing
 * @date 2022/4/22   11:10
 */
public class EmojiUtils {

    private static EmojiConverter emojiConverter = EmojiConverter.getInstance();
    /**
     * 带有表情的字符串Emoji转义为unicode，类似🙆。
     * emoji--->unicode字符串
     *
     * @param emoji
     * @return
     */
    public static String emojiConverter2Html(String emoji) {
        String result = null;
        if (null != emoji && emoji.length() > 0) {
            result = emojiConverter.toHtml(emoji);
        }
        return result;
    }

    /**
     * unicode--->emoji
     * @param emojiStr
     * @return
     */
    public static String emojiConverter2Unicode(String emojiStr) {
        String result = null;
        if (null != emojiStr && emojiStr.length() > 0) {
            result = emojiConverter.toUnicode(emojiStr);
        }
        return result;
    }
}
